import { httpClient } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { LoginLogOutputDto } from './model';
import { PageRequest, PageData } from '@/utils/common/types';
import { AjaxResult } from '@/api/model';

/** 管理-登录日志信息枚举 */
enum Api {
  /** 读取登录日志 */
  Read = '/api/admin/loginLog/read',
  /** 删除登录日志 */
  Delete = '/api/admin/loginLog/delete',
}

//#region 读取登录日志
/**
 * 读取登录日志
 * @param request 分页请求
 * @param mode 错误消息模型
 */
export function readLoginLogs(request: PageRequest, mode: ErrorMessageMode = 'message') {
  return httpClient.post<PageData<LoginLogOutputDto>>(
    {
      url: Api.Read,
      params: request,
    },
    {
      errorMessageMode: mode,
    },
  );
}
//#endregion

//#region 删除登录日志
/**
 * 删除登录日志
 * @param ids 登录日志编号
 * @param mode 错误消息模型
 */
export function deleteLoginLogs(ids: (string | bigint)[], mode: ErrorMessageMode = 'message') {
  return httpClient.post<AjaxResult>(
    {
      url: Api.Delete,
      params: ids,
    },
    {
      errorMessageMode: mode,
    },
  );
}
//#endregion